﻿using KingerRobot.PCRBW.Dao;
using KingerRobot.PCRMES.Dao;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace KingerRobot.PCRBW.SpiService;

public class MesCheckImpl : IMesCheckService
{
    IMesCheckRepositories _mesCheckRepositories =new MesCheckRepositories();

    public int SnycMesCheck(MesCheck mesCheck)
    {
        Expression<Func<MesCheck, bool>> whereExpression = x => true;
        whereExpression = whereExpression.And(d => d.Id == mesCheck.Id);
       var checkList= _mesCheckRepositories.First(whereExpression);
        if (checkList == null)
        {
            return _mesCheckRepositories.Add(mesCheck);
        }
        else
        {
            return _mesCheckRepositories.Update(whereExpression, mesCheck);
        }
         
    }

}
